package com.test.java;

import java.util.Scanner;

/**
 * 给定一系列正整数，请按要求对数字进行分类，并输出以下5个数字
 * <p>
 * A1 = 能被5整除的数字中所有偶数的和；
 * A2 = 将被5除后余1的数字按给出顺序进行交错求和，即计算n1-n2+n3-n4...；
 * A3 = 被5除后余2的数字的个数；
 * A4 = 被5除后余3的数字的平均数，精确到小数点后1位；
 * A5 = 被5除后余4的数字中最大数字。
 * =============================================================
 * Version          Author          Date            Description
 * 1.0              白建         2017/12/13             创建
 * =============================================================
 */
public class Java_4
{

    private static short NUM;

    private static short[] input;

    private static int A1, A2, A3, A5;

    private static double A4;

    public static void main(String[] args)
    {

        init();
        calculateA1();
        calculateA2();
        calculateA3();
        calculateA4();
        calculateA5();
        print();
    }

    private static void init()
    {

        Scanner scanner = new Scanner(System.in);
        NUM = Short.parseShort(scanner.next());

        input = new short[NUM];
        for (int i = 0; i < NUM; i++)
        {
            input[i] = Short.parseShort(scanner.next());
        }
    }

    private static void calculateA1()
    {

        for (int i = 0; i < NUM; i++)
        {
            if (input[i] % 5 == 0 && input[i] % 2 == 0)
            {
                A1 += input[i];
            }
        }
    }

    private static void calculateA2()
    {

        boolean flag = true;
        short count = 0;
        for (int i = 0; i < NUM; i++)
        {
            if (input[i] % 5 == 1)
            {
                count++;
                if (flag)
                {
                    A2 += input[i];
                    flag = false;
                }
                else
                {
                    A2 -= input[i];
                    flag = true;
                }
            }
        }
        //todo:代码不够严谨
        if (count == 0)
        {
            A2 = -1;
        }
    }

    private static void calculateA3()
    {

        for (int i = 0; i < NUM; i++)
        {
            if (input[i] % 5 == 2)
            {
                A3++;
            }
        }
    }

    private static void calculateA4()
    {

        short count = 0;
        for (int i = 0; i < NUM; i++)
        {
            if (input[i] % 5 == 3)
            {
                A4 += input[i];
                count++;
            }
        }
        if (count == 0)
        {
            A4 = -1;
        }
        else
        {
            A4 = A4 / count;
        }
    }

    private static void calculateA5()
    {

        A5 = -1;
        for (int i = 0; i < NUM; i++)
        {
            if (input[i] % 5 == 4)
            {
                if (input[i] > A5)
                {
                    A5 = input[i];
                }
            }
        }
    }

    private static void print()
    {

        System.out.println(
                (A1 == 0 ? "N" : A1) + " " + (A2 == -1 ? "N" : A2) + " " + (A3 == 0 ? "N" : A3) + " " + (A4 == -1 ?
                        "N" :
                        String.format("%.1f", A4)) + " " + (A5 == -1 ? "N" : A5));
    }
}
